//
//  RaiseItemTableViewCell.m
//  Kjs-iOS
//
//  Created by 江伟 on 16/7/10.
//  Copyright © 2016年 jmhz. All rights reserved.
//

#import "RaiseItemTableViewCell.h"
#import "CommonUtil.h"

@interface RaiseItemTableViewCell ()
@property (nonatomic,weak) IBOutlet UILabel *itemStatusNameLab;
@end

@implementation RaiseItemTableViewCell

- (void)awakeFromNib {
    // Initialization code
    self.raiseMoenyLab.adjustsFontSizeToFitWidth = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}
- (void)setItem:(ItemInfo *)item
{
    NSLog(@"item传进来了%@",item);
    self.itemNameLab.text = item.itemName;
    self.gdAnnualizedBenefitRateLab.text = [NSString stringWithFormat:@"%.2lf％",item.gdAnnualizedBenefitRate*100];
    self.interestDaysLab.text = [NSString stringWithFormat:@"%d天",item.interestDays];
    self.gdBenefitMode.text = [CommonUtil getGdBenefitModeStrWithMode:item.gdBenefitMode];
    NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
    formatter.numberStyle = NSNumberFormatterDecimalStyle;
    NSString *raiseMoneyStr = [formatter stringFromNumber:[NSNumber numberWithDouble:item.raiseMoney]];
    self.raiseMoenyLab.text = [NSString stringWithFormat:@"¥%@",raiseMoneyStr];
    //时间戳转换显示
    NSDateFormatter *df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"yyyy-MM-dd"];
    [df setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"zh_CN"]];
    if (item.interestStartDate != -1 && item.interestStartDate != 0) {
        NSDate *interestStartDate = [NSDate dateWithTimeIntervalSince1970:item.interestStartDate/1000];
        self.interestStartDateLab.text = [df stringFromDate:interestStartDate];
    }else{
        self.interestStartDateLab.text = @"-";
    }
    self.itemStatusLab.text = [CommonUtil getItemStatusStrWithStatus:item.itemStatus];
    //融资成功的情况
    if (item.itemStatus == 9) {
        self.itemStatusLab.text = item.gdBenefitReturnStep;
    }
    
}
@end
